<style scoped>
    .layout {
        /* border: 1px solid #d7dde4; */
        background: #f5f7f9;
        position: relative;
        /* border-radius: 4px; */
        overflow: hidden;
    }
    
    .layout-breadcrumb {
        padding: 10px 15px 0;
    }
    
    .layout-content {
        min-height: 800px;
        margin: 15px;
        overflow: hidden;
        background: #fff;
        border-radius: 4px;
    }
    
    .layout-content-main {
        padding: 10px;
    }
    
    .layout-copy {
        text-align: center;
        padding: 10px 0 20px;
        color: #9ea7b4;
    }
    
    .layout-menu-left {
        background: #464c5b;
    }
    
    .layout-header {
        height: 60px;
        background: #fff;
        box-shadow: 0 1px 1px rgba(0, 0, 0, .1);
    }
    
    .layout-logo-left {
        width: 90%;
        height: 30px;
        background: #5b6270;
        border-radius: 3px;
        margin: 15px auto;
        color: #d7dde4;
        line-height: 30px;
        font-size: 25px;
    }
    
    .layout-ceiling-main a {
        color: #9ba7b5;
    }
    
    .layout-hide-text .layout-text {
        display: none;
    }
    
    .ivu-col {
        transition: width .2s ease-in-out;
    }
</style>

<template>
    <div class="layout" :class="{'layout-hide-text': spanLeft < 4}">
        <Row type="flex">
            <Col :span="spanLeft" class="layout-menu-left">
            <Menu active-name="1" theme="dark" width="auto">
                <div class="layout-logo-left">我的彩票</div>
                    <dynamic-menus :items="menus"></dynamic-menus>
                </Menu>
            </Col>
            <Col :span="spanRight">
                <div class="layout-header">
                    <Button type="text" @click="toggleClick">
                        <Icon type="navicon" size="32"></Icon>
                    </Button>
                </div>
                <div class="layout-breadcrumb">
                    <Breadcrumb>
                        <BreadcrumbItem href="#">Index</BreadcrumbItem>
                        <BreadcrumbItem href="#">Apps</BreadcrumbItem>
                        <BreadcrumbItem>App</BreadcrumbItem>
                    </Breadcrumb>
                </div>
                <div class="layout-content">
                    <div class="layout-content-main">Content</div>
                </div>
                <div class="layout-copy">
                    2011-2016 &copy; ilottery
                </div>
            </Col>
        </Row>
    </div>
</template>

<script>

    import DynamicMenus from './DynamicMenus'

    export default {
        components:{DynamicMenus},
        data() {
            return {
                spanLeft: 4,
                spanRight: 20,
                menus:[]
            }
        },
        beforeMount() {
            this.menus=this.$root.$root.$options.router.options.routes;
        },
        computed: {
            iconSize() {
                return this.spanLeft === 4 ? 14 : 24;
            }
        },
        methods: {
            toggleClick() {
                if (this.spanLeft === 4) {
                    this.spanLeft = 1;
                    this.spanRight = 23;
                } else {
                    this.spanLeft = 4;
                    this.spanRight = 20;
                }
            }
        }
    }
</script>